package com.lagou.server;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerInit {
    private ServerSocket serverSocket;
    private Socket s;
    private  ObjectInputStream ois;
    private  ObjectOutputStream oos;

    public ObjectInputStream getOis() {
        return ois;
    }

    public void setOis(ObjectInputStream ois) {
        this.ois = ois;
    }

    public ObjectOutputStream getOos() {
        return oos;
    }

    public void setOos(ObjectOutputStream oos) {
        this.oos = oos;
    }

    public void serverInit() throws IOException {
        serverSocket = new ServerSocket(8888);
       System.out.println("等待客户端连接");
        s = serverSocket.accept();
       System.out.println("客户端连接成功");
       ois = new ObjectInputStream(s.getInputStream());
       oos = new ObjectOutputStream(s.getOutputStream());
        System.out.println("服务器初始化成功");



   }
   public void serverClose() throws IOException {
         oos.close();
         ois.close();
         s.close();
         serverSocket.close();
       System.out.println("服务器成功关闭");
   }

}
